package com.cn.demo.springboot.vo;

import java.io.Serializable;



/**
 * Json请求响应消息
 * @author lenovo
 */
public class ResponseMsg<T> implements Serializable {

	private static final long serialVersionUID = 5677333651679329978L;
	
	public static final Integer STATUS_SUCCESS = 0;
	public static final Integer STATUS_FAILED = -1;
	public static final Integer AUTHORIZATION_DENIED = 403;//权限不足
	
	/**状态编码*/
	private Integer status=0;
	/**返回消息*/
	private String msg="";
	/**返回数据*/
	private T data;
	
	public ResponseMsg() {
	}
	public ResponseMsg(T data) {
		setData(data);
	}
	public ResponseMsg(Integer status,String msg){
		setStatus(status);
		setMsg(msg);
	}
	public ResponseMsg(T data,Integer status) {
		setData(data);
		setStatus(status);
	}
	/**
	 * 返回状态:0,成功;-1失败
	 * @return
	 */
	public Integer getStatus() {
		return status;
	}
	/**
	 * 返回状态:0,成功;-1失败
	 * @return
	 */
	public void setStatus(Integer status) {
		this.status = status;
	}
	/**
	 * 返回状态说明
	 * @return
	 */
	public String getMsg() {
		return msg;
	}
	/**
	 * 返回状态说明
	 * 正常时，可以使访问图片的url
	 * @return
	 */
	public void setMsg(String msg) {
		this.msg = msg;
	}
	/**
	 * 返回数据
	 * @return
	 */
	public T getData() {
		return data;
	}
	/**
	 * 返回数据
	 * @return
	 */
	public void setData(T data) {
		this.data = data;
	}
	/**
	 * 返回文件的状态
	 * @return
	 */
	public Integer getError(){
		return status;
	}
	/**
	 * 返回文件的访问路径
	 * 对应ResponseMsg对象的msg属性的值,在上传文件成功时时保存的是文件的远程访问url	 
	 * @return
	 */
	public String getUrl(){
		return msg;
	}
	
	public void failed(String msg)
	{
		this.setStatus(STATUS_FAILED);
		this.setMsg(msg);
	}
}
